package com.lc.qianrenshiye.conn;

import com.zcx.helper.http.AsyCallBack;
import com.zcx.helper.http.note.HttpInlet;

import org.json.JSONObject;

/**
 * Created by Administrator on 2016/12/6.
 */
@HttpInlet(Conn.STORE_USER)
public class UserInfoPost extends BaseAsyPost<UserInfoPost.UserInfoEntity> {

    public String sid;

    public UserInfoPost(AsyCallBack<UserInfoEntity> asyCallBack) {
        super(asyCallBack);
    }

    @Override
    protected UserInfoEntity parser(JSONObject object) throws Exception {

        if (object.optInt("code") == 200) {

            JSONObject entityObject = object.optJSONObject("data");

            UserInfoEntity userInfoEntity = new UserInfoEntity();

            userInfoEntity.sid = entityObject.optString("sid");
            userInfoEntity.title = entityObject.optString("title");
            userInfoEntity.phone = entityObject.optString("phone");
            userInfoEntity.picurl = Conn.IMAGE_URL + entityObject.optString("picurl");
            userInfoEntity.licence = Conn.IMAGE_URL + entityObject.optString("licence");
            userInfoEntity.username = entityObject.optString("username");

            return userInfoEntity;

        }

        return null;
    }

    public static class UserInfoEntity {

        public String sid, title, phone, picurl, licence, username;

    }
}
